package com.zhou.common.quartz.test.wheel;

import cn.hutool.core.thread.ThreadUtil;
import com.zhou.base.components.log.trace.scheduled.LogTraceScheduledThreadPoolExecutor;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.boot.task.TaskSchedulerBuilder;

import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * jdk {@link ScheduledThreadPoolExecutor}的扩展类增加日志打印
 *
 * @author xianfeng
 * @date 2023/12/21 18:47
 * @description:
 */
@Slf4j
public class JdkScheduledExtend {

    @Test
    public void test1() {
        LogTraceScheduledThreadPoolExecutor executor = new LogTraceScheduledThreadPoolExecutor(2);
        executor.schedule(() -> {
            log.info("执行了任务1");
        }, 5000, TimeUnit.MILLISECONDS);
        executor.schedule(() -> {
            log.info("执行了任务2");
        }, 5000, TimeUnit.MILLISECONDS);
        executor.schedule(() -> {
            log.info("执行了任务3");
        }, 1000, TimeUnit.MILLISECONDS);
        ThreadUtil.sleep(1000 * 1000);
    }

    @Test
    public void test2() {
        TaskSchedulerBuilder builder = new TaskSchedulerBuilder();
    }
}
